package traveler.tools;


import traveler.activities.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
    int mGalleryItemBackground;
    private Context mContext;
    
    private int[] mImageIds = {
            R.drawable.tour_eiffeil_diapo,
            R.drawable.triomphe,
            R.drawable.louvre,
            R.drawable.dame,
            //R.drawable.coeur,
            R.drawable.moulin,
            R.drawable.seine,
            R.drawable.opera
    };

    public ImageAdapter(Context c) {
        mContext = c;
        TypedArray attr = mContext.obtainStyledAttributes(R.styleable.SocialGallery);
        mGalleryItemBackground = attr.getResourceId(
                R.styleable.SocialGallery_android_galleryItemBackground, 0);
        attr.recycle();
        
        
    }
    
    public ImageAdapter(Context c, int[] imgIds)
    {
    	this(c);
    	
    	mImageIds = imgIds;
    }

    public int getCount() {
        return mImageIds.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView = new ImageView(mContext);

        imageView.setImageResource(mImageIds[position]);
        imageView.setLayoutParams(new Gallery.LayoutParams(170, 150));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setBackgroundResource(mGalleryItemBackground);
        

        return imageView;
    }
}
